/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package radio.sessions;

<<<<<<< .mine
import java.util.List;
=======
import java.util.List;
import javax.ejb.EJB;
>>>>>>> .r54
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import radio.entities.Accounts;
import radio.entities.PaymentDetails;

/**
 *
 * @author Huu Vinh
 */
@Stateless
public class PaymentDetailsFacade extends AbstractFacade<PaymentDetails> {

    @EJB
    private AccountsFacade accountsFacade;
    @PersistenceContext(unitName = "RadioCabsEJB-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public PaymentDetailsFacade() {
        super(PaymentDetails.class);
    }

    public List<PaymentDetails> getIdByStatus(boolean b) {
        return em.createNamedQuery("PaymentDetails.findByStatus").setParameter("status", b).getResultList();
    }

    public PaymentDetails findByAccId(String accId) {
        return (PaymentDetails) em.createNamedQuery("PaymentDetails.findByAccId").setParameter("accId", accId).getResultList().get(0);
    }
    
<<<<<<< .mine
    public PaymentDetails checkupgrade(int accId){
        List<PaymentDetails> result = em.createNamedQuery("PaymentDetails.checkupgrade").setParameter("accId", accId).getResultList();
        if (!result.isEmpty()) {
            return result.get(0);
        } else {
            return null;
        }
    }
=======

//    public boolean confirmPayment(String uid, int typeId, PaymentDetails pm) {
//        try {
//            em.getTransaction().begin();
//            em.getTransaction().setRollbackOnly();
//            pm.setStatus(false);
//            accountsFacade.confirmPayment(uid, typeId);
//            edit(pm);
//            em.getTransaction().commit();
//        } catch (Exception ex) {
//            em.getTransaction().rollback();
//            return false;
//        }
//        return true;
//    }
>>>>>>> .r54
}
